#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"

#define LED_GPIO GPIO_NUM_27

// 创建一个方法用于改变gpio 引脚状态
void led_run_task(void *param){
    int gpio_level = 0;
    while(1){
        gpio_level = gpio_level? 0:1;
        gpio_set_level(LED_GPIO, gpio_level);
        vTaskDelay(pdMS_TO_TICKS(500));
    }
}

void app_main(void)
{
    // 配置 gpio
    gpio_config_t led_cfg = {
        .pin_bit_mask = (1<<LED_GPIO),
        .pull_up_en = GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .mode = GPIO_MODE_OUTPUT,
        .intr_type = GPIO_INTR_DISABLE,
    };

    // 配置 gpio 引脚
    gpio_config(&led_cfg);
    
    // 创建任务
    xTaskCreatePinnedToCore(led_run_task, "led",2048,NULL,3,NULL,1);
}
